package com.cxs.utils;

import org.apache.commons.fileupload.FileItem;

import java.io.File;
import java.io.IOException;

/**
 * @Project: file-upload-demo
 * @Author: cxs2014501@163.com
 * @Create: 2023/3/6 16:31
 * @Description:
 **/
public class FileUploadUtil {
    public static String upload(FileItem fileItem) throws Exception {
        // 文件的上传路径
        String address = "E:\\ideaProjects\\aaa\\file-upload-demo\\images";
        //文件的绝对地址
        String solutionAddress = address + File.separator + fileItem.getName();
        File file = new File(solutionAddress);
        if (!file.exists()) {
            file.createNewFile();
        }
        fileItem.write(file);
        return solutionAddress;
    }
}
